# -*- coding: utf-8 -*-
# @Time : 2019/1/14 12:18
# @Author : Administrator
# @File : resource.py
# @Project : untitled
# @title :培训资源
import requests,unittest,ddt
from WoniuBoss2.interface.tools.read_excel import ReadExcel
from HTMLTestRunner import HTMLTestRunner
@ddt.ddt
class Resource(unittest.TestCase):
    data = ReadExcel()  # 实例化
    # 通过传入文件路径和sheet名称获取参数列表
    info = data.read_data("C:\\Users\\Administrator\\PycharmProjects\\untitled\\WoniuBoss2\\interface\\data\\resource.xls", "王者荣耀")
    modify = data.read_data("C:\\Users\\Administrator\\PycharmProjects\\untitled\\WoniuBoss2\\interface\\data\\resource.xls", "modify")
    @classmethod #装饰器
    def setUpClass(cls): #登录
        cls.session = requests.session()  #实例化session
        cls.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/log/userLogin",
                      data={"userName":"wncd000","userPass":"woniu123","checkcode":"0000"})

    # 新增资源
    # @ddt.data(*info)
    # def test_001_add(self,value):
    #     self.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/cons/showCusInfo",
    #                     data={"tel":value["tel"]})   #此处有一个post请求，电话请求
    #     res = self.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/cons/addCus",
    #                             data = {"cus.tel":value["tel"],"cus.name":value["name"],"cus.sex":"男",
    #                                     "cus.last_status":"新入库","cus.email":0,"cus.qq":value["QQ"],
    #                                     "cus.school":value["school"],"cus.education":"本科","cus.major":value["major"],
    #                                     "cus.intent":value["job"],"cus.workage":"应届毕业生","cus.salary":"",
    #                                     "cus.source":"双选会","cus.applposition":"","cus.age":value["age"],"cus.eduexp":"",
    #                                     "cus.experience":value["exp"],"cus.last_tracking_remark":value["fav"]})
    #     self.assertIn(value["expect"],res.text)   #断言

    # 修改资源
    # @ddt.data(*modify)
    # def test_002_modify(self,value):
    #     res = self.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/resource/modifyCusInfo",
    #                             data = {"cus.tel":value["tel"],"cus.name":value["name"],"cus.sex":"男",
    #                                     "cus.last_status":"新入库","cus.email":0,"cus.qq":value["QQ"],
    #                                     "cus.school":value["school"],"cus.education":"本科","cus.major":value["major"],
    #                                     "cus.intent":value["job"],"cus.workage":"应届毕业生","cus.salary":"",
    #                                     "cus.source":"双选会","cus.applposition":"","cus.age":value["age"],"cus.eduexp":"",
    #                                     "cus.experience":value["exp"],"cus.last_tracking_remark":value["fav"]})
    #     self.assertIn(value["expect"],res.text)   #断言

    #解密功能
    # def test_003_decode(self):
    #     res = self.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/second?vp=woniu123",
    #                   data={"vp":"woniu123"})
    #     # print(res.text)
    #     self.assertEqual("yes",res.text)  #断言

    # 跟踪资源
    # def test_004_fellow(self):
    #     res = self.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/resource/saveTrackingRecord",
    #                   data={"fee":"18800元","id":"592832","nextTime":"2019-01-24","priority":"低","remark":"哈哈哈哈",
    #                         "status":"已上门"})
    #     # print(res.text)
    #     self.assertEqual("success",res.text)  #断言

    # 转交责任人
    # def test_005_transmit(self):
    #     res = self.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/transmit/updateTransmit",
    #                   data={"arr[]":"592831","workId":"WNCD023"})
    #     # print(res.text)
    #     self.assertEqual("success",res.text)  #断言

    # 学院管理修改信息
    # def test_002_modify(self):
    #     res = self.session.post(url="http://192.168.187.128:8080/WoniuBoss2.5/student/saveNewInfo",
    #                      files = {"class_no":(None,"WNCDC034"),"img": (open(r"C:\Users\Administrator\PycharmProjects\untitled\WoniuBoss2\interface\data\20190114165859.png", mode="rb")),
    #                     "stu.age":"","stu.education":(None,"本科"),"stu.email":(None,""),
    #                     "stu.emergency_person":(None,""),"stu.emergency_tel":(None,""),"stu.graduation_time":(None,""),
    #                      "stu.IDnumber":(None,""),"stu.major":(None,"计算机科学与技术"),"stu.QQ":(None,"0"),"stu.school":(None,"西南石油大学"),
    #                      "stu.sex":(None,"男"),"stu.source":(None,"智联招聘"),"stu.status":(None,"在校学习"),"stu.student_id":(None,"1272"),
    #                     "stu.student_name":(None,"李杨"),"stu.student_no":(None,"WNCD201805039"),"stu.tel":(None,"18321936505")})
    #     self.assertIn("success",res.text)  #断言


if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTests(unittest.TestLoader().loadTestsFromTestCase(Resource))
    with open(r"C:\Users\Administrator\PycharmProjects\untitled\WoniuBoss2\interface\report\testReport.html","w",encoding="utf8") as file:
        runner = HTMLTestRunner(stream=file,verbosity=2,title="新增修改资源测试",description="新增修改资源的参数化测试")
        runner.run(suite)

